package com.serkol.ams.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.ams.bean.MyPage;
import com.serkol.ams.bean.MyPageOld;
import com.serkol.ams.entity.Banks;
import com.serkol.ams.mapper.BanksMapper;
import com.serkol.ams.service.BanksService;
import com.serkol.handler.MyLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author pingan
 * @description 针对表【banks】的数据库操作Service实现
 * @createDate 2022-12-08 00:36:26
 */
@Service
public class BanksServiceImpl extends ServiceImpl<BanksMapper, Banks>
        implements BanksService {

    @Override
    public List<Map<String, Object>> findBanksMiniList() {
        MyLambdaQueryWrapper<Banks> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.langName(Banks::getName, Banks::getNameUg).as("name").select(Banks::getId, Banks::getStatus, Banks::getType,Banks::getColor,Banks::getIcon).ne(Banks::getStatus,1);

        List<Map<String, Object>> maps = this.listMaps(queryWrapper);

        return maps;
    }

    @Override
    public MyPage<Banks> findBanksList(int pageSize, int current) {
        QueryWrapper<Banks> queryWrapper = new QueryWrapper<>();

        queryWrapper.orderByDesc("ID");
        Page<Banks> page = new Page<>(current, pageSize);
        Page<Banks> mapPage = this.baseMapper.selectPage(page, queryWrapper);
        return MyPage.parsePage(mapPage);
    }

}




